// const container = document.getElementById('container')
// let selection = window.getSelection();
// container!.addEventListener('beforeinput', (e) => {
//   // console.log(e)
//   // let index = 0
//   // console.log(window.getSelection())

//   // const cache = (e.target as HTMLElement).innerHTML;
//   (e.target as HTMLElement).innerHTML += e.data
//   // console.log((cache + e.data))
//   // console.log((cache + e.data).length - 3);

//   // console.log(selection, '11111111111111111111111111111')
//   e.preventDefault()
// })
// document!.addEventListener('selectionchange', (e) => {
//   console.log('change', e)
//   selection!.setPosition(container!.childNodes[0], 9)
//   console.log(selection, '11111111111111111111111111111')
//   // console.log(e, '123123')
//   // if (e.key === 'Delete') {
//   //   console.log('删除')
//   // }
// })



// import { beforeinput, selectionchange } from '@/EventHandler/index'
// const dom = document.querySelector('#container')

// if (dom) {
//   dom.addEventListener('beforeinput', beforeinput)
// }

// document.addEventListener('selectionchange', selectionchange)

import Editor from "./editor";
import { toUpperCasePlugin, UndoRedoPlugin } from './plugins'

window.onload = () => {
  const editor = UndoRedoPlugin(toUpperCasePlugin(new Editor(document.getElementById('container') as HTMLElement)))
  editor.init()
}
